<style lang="less" scoped>
</style>
<template>
    <base-model
        @model-close="modelClose"
        @model-ok="modelOk"
        title="修改订单"
        :value="value"
        :loading="loading"
        @input="updateshow">
        <Form :model="form" :label-width="120" :ref="ref" :rules="rule">
            <FormItem label="客户订单编号：" prop="customernub">
                <base-input v-model="form.customernub" placeholder="请输入客户订单编号"></base-input>
            </FormItem>
            <FormItem label="数量：" prop="number">
                <base-input v-model="form.number" placeholder="请输入订单数量"></base-input>
            </FormItem>
            <FormItem label="总批次：" prop="allbatch">
                <base-input v-model="form.allbatch" placeholder="请输入总批次数"></base-input>
            </FormItem>
            <FormItem label="交期：" prop="delivery">
                <DatePicker :value="form.delivery" type="date" placeholder="Select date" style="width: 200px" @on-change="data => {form.delivery = new Date(data).getTime()}"></DatePicker>
            </FormItem>
            <FormItem label="预计出货时间：" prop="deliveryTime">
                <DatePicker :value="form.deliveryTime" type="date" placeholder="Select date" style="width: 200px"  @on-change="data => {form.deliveryTime = new Date(data).getTime()}"></DatePicker>
            </FormItem>
        </Form>
    </base-model>
</template>
<script>
    export default {
        name: 'adduser',
        props: {
            value: {
                type: Boolean,
                default: false
            },
            customer: {
                type: Array,
                default: () => {
                    return []
                }
            },
            product: {
                type: Array,
                default: () => {
                    return []
                }
            }
        },
        data () {
            return {
                ref: 'addorder',
                /*customer: [
                    {
                        value: 'kh001',
                        label: '杭州肯沃自动化有限公司'
                    },
                    {
                        value: 'kh002',
                        label: '杭州肯沃自动化有限公司2'
                    },
                    {
                        value: 'kh003',
                        label: '杭州肯沃自动化有限公司3'
                    },
                    {
                        value: 'kh005',
                        label: '杭州肯沃自动化有限公司4'
                    },
                    {
                        value: 'kh004',
                        label: '杭州肯沃自动化有限公司5'
                    },
                    {
                        value: 'KH4584sadd1sad',
                        label: 'KH4584sadd1sad'
                    }
                ],
                product: [
                    {
                        value: 'cp0001',
                        label: 'cp1251x454x145'
                    },
                    {
                        value: 'cp0002',
                        label: 'cp1251x454x145'
                    },
                    {
                        value: 'cp0003',
                        label: 'cp1251x454x145'
                    },
                    {
                        value: 'cp0004',
                        label: 'cp1251x454x145'
                    },
                    {
                        value: 'cp0005',
                        label: 'cp1251x454x145'
                    },
                    {
                        value: 'cp0006',
                        label: 'cp1251x454x145'
                    },
                    {
                        value: 'MT454564dsadaas',
                        label: 'MT454564dsadaas'
                    }
                ],*/
                form: {
                    customernub: '',
                    number: '',
                    allbatch: '',
                    delivery: '',
                    deliveryTime: ''
                },
                loading: true,
                rule: {
                    nub: this.rule.noNull('用户名不能为空')
                }
            }
        },
        computed: {
        },
        methods: {
            setForm (form) {
                this.form = form
            },
            updateshow (show) {
                this.$emit('input', show)
            },
            editorderupdate (data) {
                this.$emit('editorderupdate', data)
            },
            reset () {
                this.$refs[this.ref].resetFields();
            },
            modelClose () {
                this.reset()
            },
            modelOk () {
                console.log(this.form)
                this.$refs[this.ref].validate((valid) => {
                    if (valid) {
                        this.loading = true
                        this.http.updateOrder(this, this.form)
                        //setTimeout(() => {
                            /*this.loading = false
                            setTimeout(() => {
                                this.loading = true
                            }, 100)
                            //this.reset()
                            this.form = {
                                name: '',
                                password: '',
                                passwordcheck: '',
                                power: []
                            }
                            this.$emit('input', false)
                            this.$Notice.success({
                                title: '订单添加成功',
                                desc: ''
                            });
                            this.$emit('input', false)
                        }, 2000);*/
                    } else {
                        this.loading = false
                        setTimeout(() => {
                            this.loading = true
                        }, 300)
                    }
                })

            }
        },
        components: {
        },
        mounted: function () {
        }
    };
</script>
